//箭头函数
//ES6标准新增了一种新的函数：Arrow Function（箭头函数）。

x => x*x
/* 上面的箭头函数相当于

function (x) {
    x*x
} 

*/

//无法得到预期结果
var a={
    name:'辣椒油',
    birth:2001,
    age:function(){
        var a1=this.birth
        var a2=function(){
            return new Date().getFullYear()-this.birth
        };
        return a2()
    }
}

var b={
    name:'辣椒油',
    birth:2001,
    age:function(){
        var b1=this.name;
        var fn =()  => new Date().getFullYear()-this.birth;
        return fn();
    }

}
console.log(b.age());   //20









//////了解...rest
'use strict'
let abc=(x,y,...rest)=>{
    console.log(x);
    console.log(y);
    console.log(rest);
}
abc()  //underfined,underfined,[]
abc(1)  //1(即为x),underfined,[]
abc(1,2)  //1(即为x),2(即为y),[]
abc(1,2,3)  //1(即为x),2(即为y),[3](即为rest)
abc(1,2,3,4,5,6)  //1(即为x),2(即为y),[3,4,5,6](即为rest,x和y后多出来的)